<include file="public@header"/>
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="{:url('AdminInvoice/index')}">所有发票</a></li>
    </ul>
    <form class="well form-inline margin-top-20" method="get" action="{:url('AdminInvoice/index')}">
        发票号:
        <input type="text" class="form-control" name="invoice_no" style="width: 200px;"
               value="{:input('param.invoice_no','')}" placeholder="发票号...">
        发票抬头:
        <input type="text" class="form-control" name="title" style="width: 200px;"
               value="{:input('param.title','')}" placeholder="发票抬头...">
        <input type="submit" class="btn btn-primary" value="搜索"/>
        <a class="btn btn-danger" href="{:url('AdminInvoice/index')}">清空</a>
    </form>
    <form method="post" class="js-ajax-form margin-top-10" action="{:url('Link/listOrder')}">
        <php>$status=array("1"=>lang('DISPLAY'),"0"=>lang('HIDDEN'));</php>
        <table class="table table-hover table-bordered table-list">
            <thead>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x"
                               data-checklist="js-check-x">
                    </label>
                </th>
                <th width="50">ID</th>
                <th width="20%">发票号</th>
                <th>发票类型</th>
                <th>单位名称</th>
                <th>订单信息</th>
                <th>申请时间</th>
                <th width="120">{:lang('ACTIONS')}</th>
            </tr>
            </thead>
            <tbody>
            <foreach name="invoices" item="vo">
                <tr>
                    <td>
                        <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]"
                               value="{$vo.id}">
                    </td>
                    <td>{$vo.id}</td>
                    <td>
                        <input class="form-control input-invoice_no" type="text"
                               value="{$vo.invoice_no}"
                               placeholder="{$vo.invoice_no|default='未开发票'}"
                               style="width: 200px;display: inline-block;" data-id="{$vo.id}"/>
                    </td>
                    <td>
                        <eq name="vo.type" value="2">
                            普通发票
                        </eq>
                        <eq name="vo.type" value="3">
                            专用发票
                        </eq>
                    </td>
                    <td>{$vo.title}</td>
                    <td>
                        <php>$invoice_amount=0;</php>
                        <foreach name="vo.orders" item="order">
                            <php>$invoice_amount+=$order['order_amount'];</php>
                            <div>{$order.order_sn} &nbsp;<b>￥{$order.order_amount}</b></div>
                        </foreach>
                        <div><b>总金额:</b>￥{$invoice_amount}</div>
                    </td>

                    <td>{:date('Y-m-d',$vo.create_time)}<br>{:date('H:i:s',$vo.create_time)}</td>
                    <td>
                        <a href="javascript:parent.openIframeLayer('{:url('order/AdminInvoice/detail',['id'=>$vo['id']])}','发票详情',{});">详情</a>
                    </td>
                </tr>
            </foreach>
            </tbody>
            <tfoot>
            <tr>
                <th width="16">
                    <label>
                        <input type="checkbox" class="js-check-all" data-direction="x"
                               data-checklist="js-check-x">
                    </label>
                </th>
                <th width="50">ID</th>
                <th>发票号</th>
                <th>开票类型</th>
                <th>单位名称</th>
                <th>订单信息</th>
                <th>申请时间</th>
                <th width="120">{:lang('ACTIONS')}</th>
            </tr>
            </tfoot>
        </table>
    </form>
</div>
<script src="__STATIC__/js/admin.js"></script>
<script>
    $('.input-invoice_no').change(function () {
        var $this     = $(this);
        var id        = $this.data('id');
        var invoiceNo = $this.val();
        $.ajax({
            url: "{:url('AdminInvoice/setInvoiceNo')}",
            type: "POST",
            dataType: 'json',
            data: {id: id, invoice_no: invoiceNo},
            success: function (data) {


            },
            error: function () {

            }
        })
    });
</script>
</body>
</html>